package demo2;

public class Test {
    public static void main(String[] args) {
        //第一种做法
        String s = "asdf asdf  asdf rtgh werasedfr";
        String[] str = s.split(" ");
        System.out.println(str[str.length - 1].length());

        //第二种做法
        String s2 = "asdf asdf  asdf rtgh werasedfr";
        int index = s2.lastIndexOf(" ");
        String s1 = s2.substring(index+1);
        System.out.println(s1.length());
    }
}
